#!/usr/bin/python
#for test webpy in visualhost
import sys
sys.path.insert(0, "/usr/local/bin/python")
sys.path.insert(0, "/www/fancyhan.host/ifancc_com/htdocs/115")
sys.path.insert(0, "/www/fancyhan.host/ifancc_com/modules")
import web
from web.contrib.template import render_mako
from netcrack import netdisk



render = render_mako(
        directories=['templates'],
	module_directory="templates",
        input_encoding='utf-8',
        output_encoding='utf-8',
        )


class main:
	def GET(self):
		web.header('Content-Type','text/html')
		return render.main()
class api:
	def GET(self,code):
		web.header('Content-Type','text/javascript')
		return netdisk(code).json()


urls = (
	'/',main,
	'/api/(.*)',api,
	'/api/http://u\.115\.com/file/(.*)',api
)
app = web.application(urls,globals())

#mapping = (r'wap\.ifancc\.com',app)
#app2= web.subdomain_application(mapping)

web.wsgi.runwsgi = lambda func, addr=None: web.wsgi.runfcgi(func,addr)
 
if __name__ == '__main__':
	app.run()
	#print render.main()
		
	



